package ZengJiHong2.Test3.timer;

import java.time.Duration;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.TimerTask;
/**
 * @ClassName timeTask
 * @Author 16799
 * @Date 2025/8/19 20:51
 * @Version 1.0
 * @Description TODO
 **/
public class timeTask extends TimerTask {

    //高考时间
    private LocalDateTime startTime;

    public timeTask(){
        String s = "2023-06-07 09:00:00";
        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        startTime = LocalDateTime.parse(s,dtf);
        System.out.println("\t\t\t2023年高考倒计时");
        System.out.println("2023年高考时间：2023年06月07日 星期三");
        System.out.println("现在距离2023年高考还有：");

    }
    @Override
    public void run() {
        LocalDateTime now = LocalDateTime.now();
        Duration duration = Duration.between(startTime,now);

        System.out.println(duration.toDays()+"天"+duration.toHoursPart()+
                "时"+duration.toMinutesPart()+"分"+duration.toSecondsPart()+"秒");
    }
}
